package org.zjx.route.model;

import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.zjx.route.entity.Location;
import org.zjx.route.entity.RouteType;

import java.util.Objects;

/**
 * 回师门技能路由实现
 * 特点：师门专属、无需道具、固定耗时
 */
@JSONType(typeName = "BackToSectRoute")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class BackToSectRoute extends AbstractRoute {
    private String sectName;

    /**
     * 构造函数
     * @param start 当前位置
     * @param sectLoc 师门位置
     * @param sectName 门派名称
     */
    public BackToSectRoute(Location start, Location sectLoc, String sectName) {
        super(start, sectLoc, 2, RouteType.BACK_TO_SECT, false);
        this.sectName = Objects.requireNonNull(sectName);
        if (start.sameScene(sectLoc)) {
            throw new IllegalArgumentException("回师门必须跨场景使用");
        }
    }

    @Override
    protected Route createReverseRoute() {
        throw new UnsupportedOperationException("回师门技能只能单向使用");
    }

    @Override
    public String getDescription() {
        return String.format("施展【%s】回师门秘法（%d秒）",
                sectName, getTime());
    }
}